<%-- 
    Document   : ListProducts
    Created on : 30 mai 2012, 18:24:17
    Author     : isen
--%>

<%@page import="persistence.PersistenceImplementation"%>
<%@page import="persistence.PersistenceInterface"%>
<%@page import="model.Product"%>
<%@page import="java.util.HashMap"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>List of the products</title>
    </head>
    <body>
            <center>
                    <h1>Products in stock:</h1>
            <% String status = (String) request.getSession().getAttribute("status");%>

                    <% HashMap<String, Product> productos = PersistenceImplementation.getJDBCPersistenceManager().getProducts();
                        if (productos != null) {
                    %>

                    <table>
                        <tr><td>Nombre</td><td>Precio</td><td>Stock</td></tr>
                        <% for (Product prod : productos.values()) {%>
                        <tr>
                            <td><%= prod.getNombre()%></td>
                            <td><%= prod.getPrecio()%></td>
                            <td><%= prod.getStock()%></td>
                        </tr>
                        <% }%>
                    </table>

                    <% } else {%>
                    <p>No se han encontrado productos, disculpe las molestias</p>
                    <% }%>

            </center>
            
            <% if (status.equals("admin")) {%>
                <%@include file="/WEB-INF/include/menuAdministrador.jsp" %>
            <%} else if (status.equals("client")) {%>
                <%@include file="/WEB-INF/include/menuClient.jsp" %>
            <%}%>
                    
</body>
</html>
